package com.qdu.servlet;

import com.qdu.dao.UsersDao;
import com.qdu.entity.Users;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 查询所有用户
 *
 * @author Lenovo
 */
@WebServlet("/saus")
public class searchAllUsersServlet extends HttpServlet{

    UsersDao userdao=new UsersDao();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //用户Service实现类
        List<Users> user=userdao.getAllUsers();//前面实现类.getAll方法
        List<Users> list=new ArrayList<>();
        
        for(Users u:user)
        {
            if(u.getUstatus()==1)//找到通过审核的
            {
                list.add(u);//放到列表中
            }
        }
        req.setAttribute("list",list);
        req.getRequestDispatcher("/userForm.jsp").forward(req, resp);
    }

    
}
